<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/json.js"></script>
<script type="text/javascript">
$(function(){
	$("#submit").click(function(){
		var product_info = new Array();
		$("#drawback_detail").children().each(function(){
			if($(this).find(":first-child").find(":first-child").is(":checked"))
			{
				product_info.push($(this).find("td:first-child").find(":first-child").val());
				product_info.push($(this).find("td:last-child").prev().find(":first-child").val());
				product_info.push($(this).find(":last-child").find(":first-child").val());
			}
		});
		$("#product_info").val($.toJSON(product_info));
	});
});
</script>
<h2>修改退货单信息</h2>
<form action="<?=url('Sales::Order/ReturnEditSave')?>" method="post">
<input type="hidden" name="sales_return_id" value="<?=$sales_return['id']?>" />
<table class="form_table">
<tr>
	<th>退货单号</th>
	<td><?=$sales_return['number']?></td>
	<th>退货日期</th>
	<td><?=$sales_return['make_time']?></td>
</tr>
<tr>
	<th>销售订单号</th>
	<td><?=$sales_return['sales_order_number']?></td>
	<th>网站/店铺</th>
	<td><?=$sales_return['shop_name']?></td>
</tr>
<tr>
	<th>退货原因</th>
	<td colspan="3"><textarea rows="3" cols="50" name="reason"><?=$sales_return['reason']?></textarea></td>
</tr>
</table>
<h2>退货信息</h2>
<input type="hidden" id="product_info" name="product_info" value="" />
<table width="60%" class="list_table">
<tr>
	<th width="50">选择</th>
	<th width="50">产品编号</th>
	<th width="80">销售价格</th>
	<th width="50">销售数量</th>
	<th width="100">退货数量</th>
</tr>
<tbody id="drawback_detail">
<?foreach ($sales_order_item as $soi):?>
<tr>
	<td><input type="checkbox" value="<?=$soi['product_basic_id']?>" <?=$soi['has_return'] ? "checked='checked'" : ''?> /></td>
	<td><?=$soi['product_basic_id']?></td>
	<td><?=$sales_return['sales_symbol'] . sprintf('%.2f', $soi['sales_price'])?></td>
	<td><input type="hidden" value="<?=$soi['id']?>" /><?=$soi['quantity']?></td>
	<td><input type="text" size="3" value="<?=$soi['has_return'] ? $soi['return_quantity'] : ''?>"/></td>
</tr>
<?endforeach;?>
</tbody>
</table>
<input type="hidden" name="history" value="<?=$_SERVER['HTTP_REFERER']?$_SERVER['HTTP_REFERER']:url('sales::order/list')?>" /></td>
<input type="submit" id="submit" class="button" value="修改保存" />
</form>
<?php $this->_endblock(); ?>